#include "CarDB.h"
#include "tracker.h"

int const Xenter=24,Yenter=313;

unsigned int __stdcall mainFrame(void *nothing)
{
	int choose=-1;
	int number=-1;
	int lp=1;
	string printout;
	ParkinglotDB &db=ParkinglotDB::instance();
	int Run=1;
	cout << "+===========================================================+\n";
	cout << "|		Welcome to \"interactive ParkingLot\"         |\n";
	cout << "|		    The parking lot of the future           |\n";
	cout << "+===========================================================+\n";
	while(Run)
	{
		cout << "\n\n .....If you want to disable automatic prints, press 1.....\n\n";
		cout << "- If you want to recieve information about any car press 2\n";
		cout << "- If you want to recieve information about specific parking spot press 3\n";
		cout << "- To recieve state (how much cars entered today, favorite parking etc press 4\n";
//		cout << "- To find a free parking spot, press 5\n";
		
		cout << "- To recieve a log about occupied parking spots , press 6 \n";
		cout << "- To find out if specific car allowed to enter to the parking lot , press 9 \n";
		cout << "- To recieve a full log printed to a file (Log.txt) , press 10 \n";

		cout << "- In order to EXIT the program , press 0 \n";


		cin >> choose;

		switch(choose)
		{
		case 0:
			cout <<"Are you sure you want to Exit (Yes=1 / No=0) ?";
			cin  >> number;	if(number) Run=0;
			break;
		case 1: 
			cout <<"Automatic Prints Blocked, press 1 again to enable them";
			db.AutoPrint(); break;
		case 2: 
			cout <<"Enter car license plate:";
			cin  >> number;
			db.WhereIsMyCar(number,printout);
			cout << "\n" << printout;
			db.HowLongCarIn(number,printout);
			cout << "\n" << printout;
			db.WhenEntered(number,printout);
			cout << "\n" << printout;
			break;
		case 3:
			cout <<"Enter parking number:";
			cin  >> number;
			db.IsParkingAvailble(number,printout);
			cout << "\n" << printout;
			break;
		case 4: 
			db.HowManyEntered(printout);
			cout << "\n" <<printout;
			db.TheMostWantedSlot (printout);
			cout << "\n" <<printout;
			db.HowManySlotsFree(printout);
			cout << "\n" << printout;
			break;
		case 5: carArrived(cvPoint(Xenter,Yenter), lp++);
				cout << "add Arrived \n" ;
			break;
		case 6:
			db.PrintOccupiedSpots();
			break;
		case 9: 
			cout <<"Enter car license plate:";
			cin  >> number;
			db.IsEligible(number,printout);
			cout << "\n" << printout; 
			break;
		case 10:
			db.PrintLogToFile();
			break;
		}
	}

	cout << "\n\n\n\n";
	return 0;
}